import java.util.*;

public class TestDemo {
    public static void func(int[] array) {
        HashSet<Integer> set = new HashSet<>();

        for (int i = 0; i < array.length; i++) {
            set.add(array[i]);
        }
        System.out.println(set);
    }

    public static int func1(int[] array) {
        HashMap<Integer,Integer> map = new HashMap<>();

        for (int i = 0; i < array.length; i++) {
            if(map.get(array[i]) == null) {
                map.put(array[i],1);
            }else {
                int val = map.get(array[i]);
                map.put(array[i],val+1);
            }
        }

        Set<Map.Entry<Integer,Integer>> entry = map.entrySet();

        for (Map.Entry<Integer,Integer> entry1: entry) {
            if(entry1.getValue() == 1) {
                return entry1.getValue();
            }
        }

        System.out.println(map);
        return -1;


    }

    public static void func2(int[] array) {
        HashMap<Integer,Integer> map = new HashMap<>();

        for (int i = 0; i < array.length; i++) {
            if(map.get(array[i]) == null) {
                map.put(array[i],1);
            }else {
                int val = map.get(array[i]);
                map.put(array[i],val+1);
            }
        }
        System.out.println(map);
    }
    public static void main(String[] args) {
       int[] array = new int[10_0000];
       Random random = new Random();

        for (int i = 0; i < array.length; i++) {
            array[i] = random.nextInt(1_0000);
        }

        func2(array);

    }
}
